<?php
header('Content-type:text/html;charset=utf-8');
include_once("../class/mysqlclass.php");
session_start();
$id=$_GET['id'];
$s=0;
//正则判断是用户删除还是文章删除，提取id
if(preg_match('/yh/', $id)){
	$s=1;preg_match('/[0-9]+/', $id,$k);
}
if(preg_match('/wz/', $id)){
	$s=2;preg_match('/[0-9]+/', $id,$k);
}
if($s==0){
	if($id=='yonghuall'){
		$mysqli = new test;
		$mysqli = $mysqli -> Con();
		$sql ="delete from `user`";
    	$res = $mysqli->query($sql);
		$_SESSION['id']= NULL;
		echo "<script>alert('所有用户已成功被删除！');location.href='manager.php?id=yh1';</script>";
		exit();
	}
	if($id=='wenzhangall'){
		$mysqli = new writing;
		$mysqli = $mysqli -> Con();
		$sql ="delete from `write` ";
    	$res = $mysqli->query($sql);
		$_SESSION['id']= NULL;
		echo "<script>alert('所有文章已成功被删除！');location.href='manager.php?id=wz1';</script>";
		exit();
	}	
}
if($s==2){
	$mysqli = new writing;
	$mysqli = $mysqli -> Con();
	$sql ="delete from `write` where id= '{$k[0]}'";
    $res = $mysqli->query($sql);
	$_SESSION['id']= NULL;
	if($_SESSION['act']=='guanlizhe'){
		echo "<script>alert('该文章已成功被删除！');location.href='manager.php?id=wz1';</script>";
    }
	if($_SESSION['act']=='guanli'){
		echo "<script>alert('该文章已成功被删除！');location.href='guanli.php?id=1';</script>";
	}
	if($_SESSION['act']=='select'){
		echo "<script>alert('该文章已成功被删除！');location.href='select.php';</script>";
	}
}
if($s==1){
	$mysqli = new test;
	$mysqli = $mysqli -> Con();
	$sql ="delete from `user` where id= '{$k[0]}'";
    $res = $mysqli->query($sql);
	$_SESSION['id']= NULL;
	if($_SESSION['act']=='guanlizhe'){
		echo "<script>alert('该用户已成功被删除！');location.href='manager.php?id=yh1';</script>";
    }
}
?>